package com.wc.alorithm_blue_bridge._DFS.最大数字;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2025/3/11 20:33
 * @description
 * https://www.lanqiao.cn/courses/46292/learning/?id=3922910&compatibility=false
 */
public class Main {
    /**
     * 思路：
     * 从高位最大, 到低位最大, 就可以满足
     */
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 20;
    static int[] num = new int[N];
    static int A, B;
    static long n, res = 0;

    public static void main(String[] args) {
        n = sc.nextLong();
        A = sc.nextInt();
        B = sc.nextInt();
        int len = 0;
        while (n > 0) {
            num[++len] = (int)(n % 10);
            n /= 10;
        }
        n = len;
        dfs(len, A, B, 0);
        out.println(res);
        out.flush();
    }

    static void dfs(int u, int a, int b, int s) {
        if (u == 0) {
            res = Math.max(res, s);
            return;
        }


        int l = num[u] + a, r = num[u] - b;
        // 加法可以满足高位到9
        if (l > 9) dfs(u - 1, a - (9 - num[u]), b, s * 10 + 9);
        // 减法可以满足高位到9
        if (r <= 0) dfs(u - 1, a, b - num[u], s * 10 + 9);
        // 都不能满足的时候, 只用加法
        if (l <= 9 && r > 0) dfs(u - 1, 0, b, s * 10 + l);

    }
}


class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
